<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use App\Handlers\SendEmailHandler;

class SendEmail implements ShouldQueue
{

    protected $email;

    protected $code;

    protected $action;

    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($code, $email, $action)
    {
        $this->code = $code;
        $this->email = $email;
        $this->action = $action;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        //发送指定邮件
        app(SendEmailHandler::class)->send($this->action,$this->email,$this->code);
    }
}
